import React, { createContext, useState } from 'react';

interface CacheContextProps {
  cache: { [key: string]: any };
  setCache: React.Dispatch<React.SetStateAction<{ [key: string]: any }>>;
}

export const CacheContext = createContext<CacheContextProps>({
  cache: {},
  setCache: () => ({}),
});

export const CacheProvider: React.FC<{ children: JSX.Element }> = ({ children }) => {
  const [cache, setCache] = useState<{ [key: string]: any }>({});

  return (
    <CacheContext.Provider value={{ cache, setCache }}>
      {children}
    </CacheContext.Provider>
  );
};
